<!doctype html>
<html>
<head>
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6775988347285724"
     crossorigin="anonymous"></script>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>p</title>
</head>
<body><h2 id='下载'>下载</h2>
<p>下载资源：[链接][https://mirrors.tuna.tsinghua.edu.cn/qt/official_releases/online_installers/]</p>
<p>在下载目录打开命令行，输入</p>
<pre><code class='language-bat' lang='bat'>文件名 --mirror https://mirrors.tuna.tsinghua.edu.cn/qt
</code></pre>
<p>部分用户下载时可能出现<code>403 Forbidden</code>，可以更换镜像源至</p>
<pre><code class='language-bat' lang='bat'>文件名 --mirror http://mirrors.ustc.edu.cn/qtproject/
</code></pre>
<p><em>PS：硬盘空间一定要够，所有组件下载后共计300多GB</em></p>
<p><em>PS：Qt打开比较慢。</em></p>
<h2 id='创建文件'>创建文件</h2>
<p><img src="assets/p.assets/image-20250123114102100.png" referrerpolicy="no-referrer" alt="image-20250123114102100"></p>
<p>1.点击<code>创建项目</code></p>
<p><img src="assets/p.assets/image-20250123114135967.png" referrerpolicy="no-referrer" alt="image-20250123114135967"></p>
<p>2.点击<code>选择</code></p>
<p><img src="assets/p.assets/image-20250123114238920.png" referrerpolicy="no-referrer" alt="image-20250123114238920"></p>
<p>3.点击<code>下一步</code></p>
<p><img src="assets/p.assets/image-20250123114306396.png" referrerpolicy="no-referrer" alt="image-20250123114306396"></p>
<p>4.点击<code>下一步</code></p>
<p><img src="assets/p.assets/image-20250123114333581.png" referrerpolicy="no-referrer" alt="image-20250123114333581"></p>
<p>5.点击<code>下一步</code></p>
<p><img src="assets/p.assets/image-20250123114400748.png" referrerpolicy="no-referrer" alt="image-20250123114400748"></p>
<p>6.点击<code>下一步</code></p>
<p><img src="assets/p.assets/image-20250123114501774.png" referrerpolicy="no-referrer" alt="image-20250123114501774"></p>
<p>7.选择与您系统环境相同的编译器(可以多选)</p>
<p>例如：您是<code>Amd64位</code>，就不能选择<code>Android</code>或<code>Arm64</code>。</p>
<p><img src="assets/p.assets/image-20250123114757951.png" referrerpolicy="no-referrer" alt="image-20250123114757951"></p>
<p>8.点击<code>下一步</code>。</p>
<p><img src="assets/p.assets/image-20250123114823347.png" referrerpolicy="no-referrer" alt="image-20250123114823347"></p>
<p>9.点击<code>完成</code>。</p>
<p><img src="assets/p.assets/image-20250123115018681.png" referrerpolicy="no-referrer" alt="image-20250123115018681"></p>
<p>正常情况下，侧边栏应该有很多文件。如果您和我一样，请继续。</p>
<p>如果您的侧边栏只有一个<code>CMakeLists.txt</code>文件，请跳转到<a href='#help'>这里</a></p>
<h2 id='编写helloworld'>编写hello_world</h2>
<p>将<code>main.cpp</code>文件修改为</p>
<pre><code class='language-cpp' lang='cpp'>#include &lt;QApplication&gt;
#include &lt;QMainWindow&gt;
#include &lt;QPushButton&gt;
int main(int argc, char* argv[])
{
	QApplication a(argc, argv);
	QMainWindow w;
	QPushButton b(&amp;w);
	b.setText(&quot;Hello QT!&quot;);
	w.show();
	return a.exec();
}
</code></pre>
<p><img src="assets/p.assets/image-20250123120855244.png" referrerpolicy="no-referrer" alt="image-20250123120855244"></p>
<p>点击侧边栏倒数第三行的绿色三角运行。</p>
<p><img src="assets/p.assets/image-20250123120912676.png" referrerpolicy="no-referrer" alt="image-20250123120912676"></p>
<p>等待输出。</p>
<p><img src="assets/p.assets/image-20250123121033180.png" referrerpolicy="no-referrer" alt="image-20250123121033180"></p>
<p>或者使用release，点击小电脑图标，切换到release生成</p>
<p><img src="assets/p.assets/image-20250123121318683.png" referrerpolicy="no-referrer" alt="image-20250123121318683"></p>
<p>再次编译运行</p>
<p><img src="assets/p.assets/image-20250123121348051.png" referrerpolicy="no-referrer" alt="image-20250123121348051"></p>
<p>我们发现，不管是哪种编译方式，直接在文件夹打开，会出现以下情况。</p>
<p><img src="assets/p.assets/image-20250123121147061.png" referrerpolicy="no-referrer" alt="image-20250123121147061"></p>
<p>我们来到应用列表。</p>
<pre><code class='language-bat' lang='bat'>C:\Users\Lenovo\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Qt
</code></pre>
<p>找到对应编译器。</p>
<p><img src="assets/p.assets/image-20250123122011448.png" referrerpolicy="no-referrer" alt="image-20250123122011448"></p>
<p>点开Qt开头的程序。</p>
<p><img src="assets/p.assets/image-20250123122052668.png" referrerpolicy="no-referrer" alt="image-20250123122052668"></p>
<p>切换到文件目录。</p>
<p><img src="assets/p.assets/image-20250123122319753.png" referrerpolicy="no-referrer" alt="image-20250123122319753"></p>
<p>输入</p>
<pre><code class='language-bat' lang='bat'>windeployqt 文件名.exe
</code></pre>
<p><img src="assets/p.assets/image-20250123122414724.png" referrerpolicy="no-referrer" alt="image-20250123122414724"></p>
<p>这样目录中就多了很多文件。</p>
<p><img src="assets/p.assets/image-20250123122500751.png" referrerpolicy="no-referrer" alt="image-20250123122500751"></p>
<p>这次再打开文件。</p>
<p>就可以了。</p>
<p><img src="assets/p.assets/image-20250123122528158.png" referrerpolicy="no-referrer" alt="image-20250123122528158"></p>
<h1 id='help'>help</h1>
<p>如果侧边栏只有一个文件，请点击窗口顶部的编辑中的<code>preference</code></p>
<p><img src="assets/p.assets/image-20250123115531081.png" referrerpolicy="no-referrer" alt="image-20250123115531081"></p>
<p>请点击所选编译器，并更改配置与我一样。</p>
<p><img src="assets/p.assets/image-20250123115748763.png" referrerpolicy="no-referrer" alt="image-20250123115748763"></p>
<p>然后再去系统环境变量，将cmake添加到环境变量中。</p>
<p><img src="assets/p.assets/image-20250123120016290.png" referrerpolicy="no-referrer" alt="image-20250123120016290"></p>
<p>点击<code>path</code></p>
<p><img src="assets/p.assets/image-20250123120049916.png" referrerpolicy="no-referrer" alt="image-20250123120049916"></p>
<p>点击<code>添加</code></p>
<p>添加</p>
<pre><code class='language-bat' lang='bat'>Qt安装路径\Tools\CMake_64\bin
</code></pre>
<p>点击<code>确定</code>并重启Qt。</p>
<p>如果还是不行，请跳转到创建文件的第4步左右，并把<code>cmake</code>改为<code>qmake</code>即可。</p>
</body>
</html>
